#  发布pub.dev
#  关闭代理PUB_HOSTED_URL、FLUTTER_STORAGE_BASE_URL
#  dart format .
#  flutter clean && flutter pub get
#  flutter packages pub logout && flutter packages pub login
#  flutter packages pub publish --server=https://pub.dartlang.org --dry-run
#  flutter packages pub publish --server=https://pub.dartlang.org
#  sudo flutter packages pub publish --server=https://pub.dartlang.org -v

# 生成和优化代码
.PHONY: code
code:
	@echo "生成和优化代码，请等待..."
	@flutter pub get >/dev/null 2>&1
	@flutter pub upgrade >/dev/null 2>&1
	@flutter pub global activate intl_utils >/dev/null 2>&1
	@flutter pub global activate dart_style >/dev/null 2>&1
	@flutter pub global run intl_utils:generate >/dev/null 2>&1
	@flutter packages pub run build_runner clean >/dev/null 2>&1
	@flutter packages pub run build_runner build --delete-conflicting-outputs
	@flutter pub get >/dev/null 2>&1

# 默认UAT环境
.PHONY: run
run:
	@flutter run

# git
.PHONY: git
git:
	@git add -A && git commit -m 'xc' && git push

# 发布Android上架包(arm拆分32位和64位)
.PHONY: apk
apk:
	@flutter clean && flutter pub get
	@flutter build apk --release \
	--dart-define=AppStore=true \
	--target-platform=android-arm,android-arm64 \
	--split-per-abi
	@open build/app/outputs/flutter-apk

# 发布iOS上架App Store(自动上传App Store)
.PHONY: ipa
ipa:
	@flutter clean && flutter pub get
	@flutter build ipa --release \
	--dart-define=AppStore=true \
	--export-method=app-store
	@xcrun altool --upload-app -t ios -f build/ios/ipa/*.ipa \
	-u "xxxx.com" -p "xxxx"
